package app.widget;

import android.content.Context;
import android.view.KeyEvent;
import android.view.View;

/**
 * 消息提示框
 * @author EX-XIAOFANQING001
 * @date 2012-1-6
 * @version [Android PABank C01, @2012-1-6]
 * @description
 */
public class MessageDialogEx extends MessageDialog
{
    private boolean canNotCancel;
    
    public MessageDialogEx(Context context, boolean canNotCancel) {
        super(context);
        this.canNotCancel = canNotCancel;
    }
    
    public MessageDialogEx(Context context, 
            boolean canNotCancel, 
            String title, 
            String message, 
            String btn1Text, 
            String btn2Text,
            boolean btn1Visible, 
            boolean btn2Visible,
            View.OnClickListener btn1ClickListener,
            View.OnClickListener btn2ClickListener) {
        
        this(context, canNotCancel);
        
        setTitle(title);
        setMessage(message);
        setBtn1Text(btn1Text);
        setBtn2Text(btn2Text);
        setBtn1Visible(btn1Visible);
        setBtn2Visible(btn2Visible);
        setBtn1ClickListener(btn1ClickListener);
        setBtn2ClickListener(btn2ClickListener);
    }
    
    
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
        if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_SEARCH) {
            if (canNotCancel) {
                return true;
            }
        }
        return super.onKeyDown(keyCode, event);
    }

}

